import Vue from 'vue'
import VueI18n from 'vue-i18n'
import Cookies from 'js-cookie'
import elementEnLocale from 'element-ui/lib/locale/lang/en' // element-ui lang
import elementZhLocale from 'element-ui/lib/locale/lang/zh-CN'// element-ui lang
import elementJaLocale from 'element-ui/lib/locale/lang/ja'// element-ui lang
import elementKoLocale from 'element-ui/lib/locale/lang/ko'// element-ui lang
import elementDeLocale from 'element-ui/lib/locale/lang/de'// element-ui lang
import elementFrLocale from 'element-ui/lib/locale/lang/fr'// element-ui lang
import elementEsLocale from 'element-ui/lib/locale/lang/es'// element-ui lang
import elementThLocale from 'element-ui/lib/locale/lang/th'// element-ui lang
import elementIdLocale from 'element-ui/lib/locale/lang/id'// element-ui lang
import elementRuLocale from 'element-ui/lib/locale/lang/ru-RU'// element-ui lang


import enLocale from './en'
import zhLocale from './zh'
import jaLocale from './ja'
import koLocale from './ko'
import deLocale from './de'
import frLocale from './fr'
import esLocale from './es'
import thLocale from './th'
import idLocale from './id'
import ruLocale from './ru'


Vue.use(VueI18n);

const messages = {
  en: {
    ...enLocale,
    ...elementEnLocale
  },
  zh: {
    ...zhLocale,
    ...elementZhLocale
  },
  ja: {
    ...jaLocale,
    ...elementJaLocale
  },
  ko: {
    ...koLocale,
    ...elementKoLocale
  },
  de: {
    ...deLocale,
    ...elementDeLocale
  },
  fr: {
    ...frLocale,
    ...elementFrLocale
  },
  es: {
    ...esLocale,
    ...elementEsLocale
  },
  th: {
    ...thLocale,
    ...elementThLocale
  },
  id: {
    ...idLocale,
    ...elementIdLocale
  },
  ru:{
    ...ruLocale,
    ...elementRuLocale
  },
};


const i18n = new VueI18n({
  locale: Cookies.get('language') || 'zh', // set locale
  messages // set locale messages
});

export default i18n
